package fons.navigator.ui.configurations;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComponent;
import javax.swing.JTextField;

public class StringConfigurationComponentFactory extends AbstractConfigurationComponentFactory<String> {

	public StringConfigurationComponentFactory() {
		super(String.class);
	}

	@Override
	public JComponent getInput() {
		return new JTextField(getValue());
	}

	@Override
	public ActionListener createActionListenerFor(final JComponent component) {
		return new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				JTextField textField = (JTextField) component;
				setValue(textField.getText());
			}
		};
	}
}
